package com.top.mall.main.income.adapter

import androidx.recyclerview.widget.RecyclerView
import com.blankj.utilcode.util.ConvertUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.top.mall.R
import com.top.mall.custom.GridSpacingItemDecoration
import com.top.mall.entity.Coupon

class CouponCenterAdapter : BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_coupon_center) {
    override fun convert(holder: BaseViewHolder, item: String) {

    }
}

class CouponCashGroupAdapter :
    BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_coupon_cash_group) {
    override fun convert(holder: BaseViewHolder, item: String) {
        holder.getView<RecyclerView>(R.id.rvCouponCashGroupBody).apply {
            val decoration = GridSpacingItemDecoration(
                spanCount = 5, spacing = ConvertUtils.dp2px((16f)), includeEdge = false
            )
            if (itemDecorationCount > 0) {
                val itemDecoration: RecyclerView.ItemDecoration? = getItemDecorationAt(0)
                if (itemDecoration == null) {
                    addItemDecoration(decoration)
                }
            } else {
                addItemDecoration(decoration)
            }
        }.adapter = CouponCashChildAdapter().apply {
            val childs: MutableList<String> = mutableListOf<String>()
            for (index in 0..4) {
                childs.add(index.toString())
            }
            setNewInstance(childs)
        }
    }
}

class CouponCashChildAdapter :
    BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_coupon_cash_child) {
    override fun convert(holder: BaseViewHolder, item: String) {

    }
}

class CouponInviteAdapter :
    BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_coupon_invite_user) {
    override fun convert(holder: BaseViewHolder, item: String) {

        holder.setGone(R.id.divider7, holder.layoutPosition == data.size - 1)
    }
}

class CouponCashAdapter :
    BaseQuickAdapter<Coupon, BaseViewHolder>(R.layout.item_coupon_cash) {
    override fun convert(holder: BaseViewHolder, item: Coupon) {
        holder.setText(R.id.tvCouponCashPrice,"￥${item.money}")
    }
}